qui {
	local cnt=0
	forvalues truncation=$truncation_list {
		local cnt=`cnt'+1
	}
	capture program drop ccn_LL
	local count=0
	foreach lhs in $LHSlist { 
		local controls="${CONTROLlist_`lhs'}"
		local subsample = "$subsample"
		foreach rhs in $RHSlist { 
			foreach robust in $robust_list {
				forvalues K=$K_list {
					matrix actual_estimates_mat = J(`cnt',8,-9)
					local rowcounter = 0
					forvalues truncation=$truncation_list {
						noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME, `truncation'"
						local rowcounter = `rowcounter'+1
						use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear
						local control_length = 0
						foreach control of varlist `controls' {
							local control_length = `control_length' + 1
						}
						global control_length = `control_length'
						qui tab X_`K', generate(dumX_`K'_)

						qui ccn_LL symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit `truncation'
						matrix actual_estimates_mat[`rowcounter',1] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',2] = r(SE)		
						matrix actual_estimates_mat[`rowcounter',3] = r(DELTA)
						matrix actual_estimates_mat[`rowcounter',4] = r(DELTA_SE)
						matrix actual_estimates_mat[`rowcounter',5] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',6] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',7] = r(ESAMP)	
						matrix actual_estimates_mat[`rowcounter',8] = `truncation'	
					}
					mat colnames actual_estimates_mat = b_HetSymm se_HetSymm d_HetSymm se_d_HetSymm dt_HetSymm se_dt_HetSymm Neff_HetSymm ///
						truncation
					clear

					qui svmat actual_estimates_mat, names(col)
					replace b_HetSymm=b_HetSymm*100
					replace se_HetSymm=se_HetSymm*100
					gen LHS="`lhs'"
					gen RHS="`rhs'"
					gen Kcluster=`K'
					gen Robust="`robust'"
					save "$datapath/004_hom_results_`subsample'_`lhs'_`robust'_K`K'_LL.dta", replace
				}
			}
		}
	}			
}

